# @Author: Eric Ito
# @Date: 1/28/2009
# @Name: Project Euler Problem 21

"""


"""
from util import getFactors

def main():
	dfact = {}
	uniq = []
	for i in range(1,10001):
		sum = 0
		for j in getFactors(i,True):
			sum += j
		dfact[i] = sum
		
	for i in dfact.keys():
		try:
			if i == dfact[dfact[i]]:
				if not i == dfact[i]:
					if i not in uniq:
						uniq.append(i)
					if dfact[i] not in uniq:
						uniq.append(dfact[i])
		except:
			pass
	sum = 0
	for s in uniq:
		sum += s
	print sum
	
if __name__ == "__main__":
	main()